
package com.bash.carrep.dao.enties;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author bash
 */
@Entity
@Table(name = "login", catalog = "carrepdb", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Login.findAll", query = "SELECT l FROM Login l"),
    @NamedQuery(name = "Login.findByUsername", query = "SELECT l FROM Login l WHERE l.username = :username"),
    @NamedQuery(name = "Login.findByPassword", query = "SELECT l FROM Login l WHERE l.password = :password"),
    @NamedQuery(name = "Login.findByCreateDate", query = "SELECT l FROM Login l WHERE l.createDate = :createDate"),
    @NamedQuery(name = "Login.findByActif", query = "SELECT l FROM Login l WHERE l.actif = :actif")})
public class Login implements Serializable {
    @Basic(optional = false)
    @NotNull
    @Column(name = "createDate", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date createDate;
//    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idlogin")
//    private List<Declaration> declarationList;
//    @OneToMany(cascade = CascadeType.ALL, mappedBy = "login")
//    private List<OperationEffectue> operationEffectueList;
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 10)
    @Column(name = "username", nullable = false, length = 10)
    private String username;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "password", nullable = false, length = 45)
    private String password;
    @Basic(optional = false)
    @NotNull
    @Column(name = "actif", nullable = false)
    private int actif;
    @JoinColumn(name = "creditLevel", referencedColumnName = "idcreditLevel", nullable = false)
    @ManyToOne(optional = false)
    private CreditLevel creditLevel;

    public Login() {
    }

    public Login(String username) {
        this.username = username;
    }

    public Login(String username, String password, Date createDate, int actif) {
        this.username = username;
        this.password = password;
        this.createDate = createDate;
        this.actif = actif;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public int getActif() {
        return actif;
    }

    public void setActif(int actif) {
        this.actif = actif;
    }

    public CreditLevel getCreditLevel() {
        return creditLevel;
    }

    public void setCreditLevel(CreditLevel creditLevel) {
        this.creditLevel = creditLevel;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (username != null ? username.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Login)) {
            return false;
        }
        Login other = (Login) object;
        if ((this.username == null && other.username != null) || (this.username != null && !this.username.equals(other.username))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.bash.carrep.dao.enties.Login[ username=" + username + " ]";
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

//    @XmlTransient
//    public List<Declaration> getDeclarationList() {
//        return declarationList;
//    }
//
//    public void setDeclarationList(List<Declaration> declarationList) {
//        this.declarationList = declarationList;
//    }
//
//    @XmlTransient
//    public List<OperationEffectue> getOperationEffectueList() {
//        return operationEffectueList;
//    }
//
//    public void setOperationEffectueList(List<OperationEffectue> operationEffectueList) {
//        this.operationEffectueList = operationEffectueList;
//    }
    
}
